<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录</title>
<!-- 导入jquery -->
<script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/2.0.3/jquery-2.0.3.min.js"></script>
<!-- 把user id复制到一个js变量 -->

<!-- <script type="text/javascript" src="js/index.js"></script> -->

<script type="text/javascript">
 
    var base = '${base}';
    $(function() {
        $("#login_button").click(function() {
            $.ajax({
                url : base + "/user/login",
                type: "POST",
                data:$('#loginForm').serialize(),
                error: function(request) {
                    alert("Connection error");
                },
                dataType:"json",
                success: function(data) {
                    alert(data);
                    //var me = '<%=session.getAttribute("me") %>';
                    var me = data;
                      
                      
                        if(me=="admin"){
                        window.location.href = base+"/jsp/index.jsp";
                        }
                        else if(me!=""){
                        window.location.href = base+"/order.jsp"
                        }
                        else
                        	alert("登录失败！")
                    <%-- if (data == true) {
                    console.log('<%=session.getAttribute("me") %>');
                     var me = '<%=session.getAttribute("me") %>';
                        alert("帐号密码成功"+me);
                      
                        if(me=="admin"){
                        window.location.href = base+"/ce.jsp";
                        }
                        else{
                        window.location.href = base+"/sale.jsp"
                        }
                    } else {
                        alert("登陆失败,请检查账号密码")
                    } --%>
                }
            });
            return false;
        });
        
    });
</script>

<!-- BOOTSTRAP STYLES-->
    <link href="assets/css/bootstrap.css" rel="stylesheet" />
     <!-- FONTAWESOME STYLES-->
    <link href="assets/css/font-awesome.css" rel="stylesheet" />
        <!-- CUSTOM STYLES-->
    <link href="assets/css/custom.css" rel="stylesheet" />
     <!-- GOOGLE FONTS-->
   <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
   
   
    
</head>
<body>
<div class="container">
        <div class="row text-center ">
            <div class="col-md-12">
                <br /><br />
                <h2> 用户登录</h2>

                 <br />
            </div>
        </div>
         <div class="row ">
               
                  <div class="col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1">
                        <div class="panel panel-default">
                            <div class="panel-heading"><center>
                        <strong> 奶茶店POS系统 </strong> </center> 
                            </div>
                            
                            <div id="login_div"><center>
							    <form action="#" id="loginForm" method="post"></br></br></br>
							     <font size = 4px>用户名：</font>    <input hight = 3px name="username" type="text" value="admin"></br></br></br></br>
							        <font size = 4px>密   码：</font> <input hight = 3px name="password" type="password" value="123456"></br></br></br>
							        <button id="login_button">提交</button></br></br></br>
							        
							        </center>
							    </form>
							</div>
                          
  						</div>
                    </div>            
        </div>
    </div>
 

 <!-- SCRIPTS -AT THE BOTOM TO REDUCE THE LOAD TIME-->
    <!-- JQUERY SCRIPTS -->
    <script src="assets/js/jquery-1.10.2.js"></script>
      <!-- BOOTSTRAP SCRIPTS -->
    <script src="assets/js/bootstrap.min.js"></script>
    <!-- METISMENU SCRIPTS -->
    <script src="assets/js/jquery.metisMenu.js"></script>
      <!-- CUSTOM SCRIPTS -->
    <script src="assets/js/custom.js"></script>
    
</body>
</html>